import os
import django

# 设置Django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'community_project.settings')
django.setup()

from core.models import Report, User

print("=== 检查举报数据 ===")

# 检查所有举报记录
reports = Report.objects.all().order_by('-created_at')
print(f"总举报数量: {reports.count()}")

for report in reports:
    print(f"举报ID: {report.report_id}")
    print(f"举报人: {report.reporter.username if report.reporter else 'None'}")
    print(f"举报类型: {report.report_type}")
    print(f"举报原因: {report.reason[:50]}...")
    print(f"创建时间: {report.created_at}")
    print("-" * 50)

# 检查最新的测试举报
test_reports = Report.objects.filter(report_type='测试举报类型')
print(f"\n测试举报数量: {test_reports.count()}")

for report in test_reports:
    print(f"测试举报ID: {report.report_id}")
    print(f"举报人: {report.reporter.username if report.reporter else 'None'}")
    print(f"创建时间: {report.created_at}")

# 检查admin用户
try:
    admin_user = User.objects.get(username='admin')
    print(f"\nAdmin用户ID: {admin_user.user_id}")
    admin_reports = Report.objects.filter(reporter=admin_user)
    print(f"Admin的举报数量: {admin_reports.count()}")
except User.DoesNotExist:
    print("\nAdmin用户不存在")